package com.doublefish.doublefishrobot.ui.video.widget;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.doublefish.doublefishrobot.R;

/**
 * 作者:dugaofeng on 2024/10/31 10:55
 */
public class VideoChooseToolView extends LinearLayout {

    private TextView nameTv;
    private TextView chooseTv;
    private TextView editTv;

    private OnVideoChooseToolViewListner onVideoChooseToolViewListner;

    public VideoChooseToolView(@NonNull Context context) {
        this(context, null);
    }

    public VideoChooseToolView(@NonNull Context context, @Nullable AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public VideoChooseToolView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        initView();
    }

    public void setOnVideoChooseToolViewListner(OnVideoChooseToolViewListner onVideoChooseToolViewListner) {
        this.onVideoChooseToolViewListner = onVideoChooseToolViewListner;
    }

    public void setName(String name) {
        nameTv.setText(name);
    }

    public void setChooseTvVisibility(boolean visibility) {
        chooseTv.setVisibility(visibility ? VISIBLE : INVISIBLE);
    }

    private void initView() {
        inflate(getContext(), R.layout.view_video_choose, this);

        nameTv = findViewById(R.id.tv_video_name);
        chooseTv = findViewById(R.id.tv_choose);
        editTv = findViewById(R.id.tv_edit);

        chooseTv.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View view) {
                if (onVideoChooseToolViewListner != null) {
                    onVideoChooseToolViewListner.onChooseVideoCallback();
                }
            }
        });

        editTv.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View view) {
                if (onVideoChooseToolViewListner != null) {
                    onVideoChooseToolViewListner.onEditVideoCallback();
                }
            }
        });
    }

    public interface OnVideoChooseToolViewListner {
        void onChooseVideoCallback();
        void onEditVideoCallback();
    }

}
